package Q2;

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        // code here

        int n = scanner.nextInt();
        int k = scanner.nextInt() - 1; //终点
        int q = scanner.nextInt(); //询问次数

        int[][] arr = new int[n][n];
        int count = 0;
        while (count < n - 1) {
            count++;
            int i = scanner.nextInt() - 1;
            int j = scanner.nextInt() - 1; // i -> j
            arr[i][j] = 1;
        }

        if (method(n, k, arr)) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }

        count = 0;
        while (count < q) {
            count++;
            int num = scanner.nextInt();
            switch (num) {
                case 1:
                    int i1 = scanner.nextInt() - 1;
                    int j1 = scanner.nextInt() - 1;
                    arr[i1][j1] = 0;
                    arr[j1][i1] = 1;
                    break;
                case 2:
                    int j2 = scanner.nextInt() - 1;
                    for (int i = 0; i < n; i++) {
                        if (arr[i][j2] == 1) {
                            arr[i][j2] = 0;
                            arr[j2][i] = 1;
                        }
                    }
                    break;
                case 3:
                    int i3 = scanner.nextInt() - 1;
                    for (int j = 0; j < n; j++) {
                        if(arr[i3][j] == 1) {
                            arr[i3][j] = 0;
                            arr[j][i3] = 1;
                        }
                    }
                    break;
                case 4:
                    int index = scanner.nextInt() - 1;
                    for (int i = 0; i < n; i++) {
                        if (arr[i][index] == 1) {
                            arr[i][index] = 0;
                            arr[index][i] = 1;
                        }
                    }
                    for (int j = 0; j < n; j++) {
                        if(arr[index][j] == 1) {
                            arr[index][j] = 0;
                            arr[j][index] = 1;
                        }
                    }
                    break;
                case 5:
                    k = scanner.nextInt() - 1;
                    break;
            }

            if (method(n, k, arr)) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }

        scanner.close();
    }

    public static boolean method(int n, int k, int[][] arr) {
        for (int i = 0; i < n; i++) {
            if (i != k) {
                if (!method2(i, k, arr, n)) {
                    //无法到达
                    return false;
                }
            }
        }

        return true;
    }

    public static boolean method2(int start, int end, int[][] arr, int n) {
        Queue<Integer> queue = new LinkedList<>();
        queue.offer(start);
        while (!queue.isEmpty()) {
            int size = queue.size();
            while (size > 0) {
                size--;
                int i2 = queue.poll();
                for (int j = 0; j < n; j++) {
                    if (arr[i2][j] == 1) {
                        if (j == end) {
                            return true;
                        }
                        queue.offer(j);
                    }
                }
            }
        }

        return false;
    }
}